package com.nbsaas.boot.storage.rest.convert;

import com.nbsaas.boot.storage.data.entity.File;
import com.nbsaas.boot.storage.api.domain.simple.FileSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 列表对象转换器
*/

public class FileSimpleConvert implements Converter<FileSimple, File> {




@Override
public FileSimple convert(File source) {
    FileSimple result = new FileSimple();

                if(source.getParent()!=null){
                    result.setParent(source.getParent().getId());
                }
                result.setExtensionName(source.getExtensionName());
                result.setCreatorId(source.getCreatorId());
                result.setCreatorName(source.getCreatorName());
                result.setAddDate(source.getAddDate());
                result.setUrl(source.getUrl());
                result.setFileSize(source.getFileSize());
                result.setObjectKey(source.getObjectKey());
                result.setServerUrl(source.getServerUrl());
                result.setName(source.getName());
                result.setTenantId(source.getTenantId());
                result.setId(source.getId());
                if(source.getFileType()!=null){
                   Map<Integer,String> FileTypeMap=new HashMap<>();
                       FileTypeMap.put(1,"文件");
                       FileTypeMap.put(2,"文件夹");
                   String label=  FileTypeMap.get(source.getFileType());
                   result.setFileTypeName(label);
                }
                result.setFileType(source.getFileType());
                result.setLastDate(source.getLastDate());


    return result;
}

}